package com.ssy.lingxi.product.repository.warehouse;

import com.ssy.lingxi.product.entity.warehouse.FreightSpaceMember;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
* 会员和仓位关联表
* @author wrc
* @date 2020/7/8
*/
@Repository
public interface FreightSpaceMemberRepository extends JpaRepository<FreightSpaceMember, Long> {

    /**
    * 根据仓位Id查询会员ID集合
    * @author wrc
    * @date 2020/7/8
    */
    List<FreightSpaceMember> findByFreightSpaceIdEquals(Long freightSpaceId);

    List<FreightSpaceMember> findByMemberIdEquals(Long memberId);

    /**
    * 删除绑定的会员ID
    * @author wrc
    * @date 2020/7/9
    */
    void deleteAllByFreightSpaceIdEquals(Long  freightSpaceId);

    List<FreightSpaceMember> findAllByMemberIdIn(List<Long> memberIds);


    List<FreightSpaceMember> findAllByFreightSpaceIdIn(Set<Long> freightSpaceIds);

    List<FreightSpaceMember> findByFreightSpaceIdIn(List<Long> freightSpaceIds);


    List<FreightSpaceMember> findByMemberIdAndRoleIdAndFreightSpaceIdIn(Long memberId,Long memberRoleId,Set<Long> freightSpaceIds);

    Boolean existsByMemberIdAndRoleIdAndFreightSpaceId(Long memberId,Long memberRoleId,Long freightSpaceId);
}
